package br.com.gustavo;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AloClasseListAdapter extends BaseAdapter {
	
	private Context context;
	private List<Grupo> lista;
	
	public AloClasseListAdapter(Context context, List<Grupo> lista) {
		super();
		this.context = context;
		this.lista = lista;
	}

	@Override
	public int getCount() {
		return lista.size();
	}

	@Override
	public Object getItem(int position) {
		return lista.get(position - 1);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Grupo g = lista.get(position);
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.lista, null);
		
		// Atualiza o valor do TextView
		TextView grupo = (TextView) view.findViewById(R.id.txvGrupo);
		grupo.setText(g.getGrupo());
		
		TextView nome = (TextView) view.findViewById(R.id.txvNome);
		nome.setText(g.getParticipante());
		
		return view;
	}

}
